package com.lhh.algorithmservice.controller;

import com.lhh.algorithmservice.service.CalculateRatingService;
import com.lhh.springcommon.annotation.WebLog;
import com.lhh.springcommon.annotation.WithRequestId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李厚航
 */
@RestController
@RequestMapping("/Recommendation")
public class RecommendationController {

    private final CalculateRatingService calculateRatingService;

    @Autowired
    public RecommendationController(CalculateRatingService calculateRatingService) {
        this.calculateRatingService = calculateRatingService;
    }

    /**
     * 根据计算目标用户最相似的用户的喜好推荐
     * @param uid
     * @return
     */
    @GetMapping("/algorithm")
    @WithRequestId
    @WebLog
    public List<Integer> algorithm(@RequestParam("uid") Integer uid, @RequestParam("num") Integer num){
        return calculateRatingService.recommendVideos(uid, num);
    }
}
